﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace LCTNote.Models.ViewModels
{
    public class NguoiDungViewModel : Model
    {
        public int ma { get; set; }
        public string tenDangNhap { get; set; }
        public string matKhau { get; set; }
        public string tenHienThi { get; set; }
        public string gioiTinh { get; set; }
        public DateTime ngaySinh { get; set; }
        public string diaChi { get; set; }
        public string soDienThoai { get; set; }

        public override void assignModel(SqlDataReader dataReader)
        {
            for (int i = 0; i < dataReader.FieldCount; i++)
            {
                switch (dataReader.GetName(i))
                {
                    case "Ma":
                        ma = !dataReader.IsDBNull(i) ? dataReader.GetInt32(i) : 0; break;
                    case "TenDangNhap":
                        tenDangNhap = !dataReader.IsDBNull(i) ? dataReader.GetString(i) : null; break;
                    case "MatKhau":
                        matKhau = !dataReader.IsDBNull(i) ? dataReader.GetString(i) : null; break;
                    case "TenHienThi":
                        tenHienThi = !dataReader.IsDBNull(i) ? dataReader.GetString(i) : null; break;
                    case "GioiTinh":
                        gioiTinh = !dataReader.IsDBNull(i) ? dataReader.GetString(i) : null; break;
                    case "NgaySinh":
                        ngaySinh = !dataReader.IsDBNull(i) ? dataReader.GetDateTime(i) : DateTime.MinValue; break;
                    case "DiaChi":
                        diaChi = !dataReader.IsDBNull(i) ? dataReader.GetString(i) : null; break;
                    case "SoDienThoai":
                        soDienThoai = !dataReader.IsDBNull(i) ? dataReader.GetString(i) : null; break;
                    default:
                        break;
                }
            }
        }
    }
}
